package com.jeeplus.modules.sys.security;

import com.jeeplus.modules.sys.entity.LoginType;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.ExcessiveAttemptsException;
import org.apache.shiro.authc.credential.HashedCredentialsMatcher;
import org.apache.shiro.cache.Cache;
import org.nutz.cache.shiro.CacheManager;

import java.util.concurrent.atomic.AtomicInteger;

public class CustomCredentialsMatch extends HashedCredentialsMatcher {

    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        //增加免密登录功能，使用自定义token
        UsernamePasswordToken usertoken = (UsernamePasswordToken) token;
        //免密登录,不验证密码
        if (LoginType.NOPASSWD.equals(usertoken.getType())){
            return true;
        }
        //密码登录
        boolean matches = super.doCredentialsMatch(token, info);
        return matches;
    }
}
